package com.andy.entity;
// default package
// Generated 2016-10-6 2:36:27 by Hibernate Tools 4.0.0.Final

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * ExamUser generated by hbm2java
 */
@Entity
@Table(name = "exam_user")
public class ExamUser implements java.io.Serializable {

	private static final long serialVersionUID = 2281919437068395721L;
	private String userId;
	private String userName;
	private String password;
	private String tel;
	private String email;
	private String address;
	private Date birthday;
	private int gender;
	private Date lastLockTime;
	private int loginFailCount;
	private Set<ExamRole> examRoles;
	private Set<ExamSubject> examSubjects;

	public ExamUser() {
	}

	@Id
	@Column(name = "user_id", unique = true, nullable = false, length = 10)
	public String getUserId() {
		return this.userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	@Column(name = "user_name", nullable = false, length = 45)
	public String getUserName() {
		return this.userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Column(name = "password", nullable = false)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "tel", length = 20)
	public String getTel() {
		return this.tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	@Column(name = "email")
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "address")
	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "birthday", nullable = false, length = 10)
	public Date getBirthday() {
		return this.birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	@Column(name = "gender", nullable = false)
	public int getGender() {
		return this.gender;
	}

	public void setGender(int gender) {
		this.gender = gender;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "last_lock_time", nullable = true, length = 10)
	public Date getLastLockTime() {
		return lastLockTime;
	}

	public void setLastLockTime(Date lastLockTime) {
		this.lastLockTime = lastLockTime;
	}

	@Column(name = "login_fail_count", nullable = false, length = 1)
	public int getLoginFailCount() {
		return loginFailCount;
	}
	
	public void setLoginFailCount(int loginFailCount) {
		this.loginFailCount = loginFailCount;
	}

	@ManyToMany(cascade = {CascadeType.DETACH, CascadeType.PERSIST, CascadeType.MERGE})
	@JoinTable(
			name = "exam_user_role",//使用@JoinTable标签的name属性注解第三方表名称
			joinColumns={
					@JoinColumn(name="user_id")
			},
			//使用joinColumns属性来注解当前实体类在第三方表中的字段名称并指向该对象
			inverseJoinColumns={@JoinColumn(name="role_id")}
			//使用inverseJoinColumns属性来注解当前实体类持有引用对象在第三方表中的字段名称并指向被引用对象表
			)
	public Set<ExamRole> getExamRoles() {
		return examRoles;
	}
	
	public void setExamRoles(Set<ExamRole> examRoles) {
		this.examRoles = examRoles;
	}
	
	@ManyToMany(cascade = {CascadeType.DETACH, CascadeType.PERSIST, CascadeType.MERGE})
	@JoinTable(
			name = "exam_user_subject",//使用@JoinTable标签的name属性注解第三方表名称
			joinColumns={
					@JoinColumn(name="user_id")
			},
			//使用joinColumns属性来注解当前实体类在第三方表中的字段名称并指向该对象
			inverseJoinColumns={@JoinColumn(name="sub_id")}
			//使用inverseJoinColumns属性来注解当前实体类持有引用对象在第三方表中的字段名称并指向被引用对象表
			)
	public Set<ExamSubject> getExamSubjects() {
		return examSubjects;
	}

	public void setExamSubjects(Set<ExamSubject> examSubjects) {
		this.examSubjects = examSubjects;
	}

	@Override
	public String toString() {
		return "ExamUser [userId=" + userId + ", userName=" + userName + ", password=" + password + ", tel=" + tel
				+ ", email=" + email + ", address=" + address + ", birthday=" + birthday + ", gender=" + gender
				+ ", examRoles=" + examRoles + "]";
	}

}
